package com.ylbh.modules.member.controller;

import com.ylbh.common.exception.NormalException;
import com.ylbh.common.pojo.member.dto.ShoppingVoucherRechargeListDTO;
import com.ylbh.common.utils.CommonResult;
import com.ylbh.common.utils.PageUtils;
import com.ylbh.common.utils.Ref;
import com.ylbh.modules.member.service.ShoppingVoucherRechargeService;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RequestMapping("user")
@RestController
public class ShoppingVoucherRechargeController {

    @Autowired
    private ShoppingVoucherRechargeService shoppingVoucherRechargeService;

    @ApiOperation("购物券充值记录")
    @RequestMapping("recharge")
    @RequiresPermissions("user:recharge")
    public CommonResult<PageUtils> queryShoppingVoucherRechargeList(ShoppingVoucherRechargeListDTO rechargeListDTO) {
        PageUtils list = shoppingVoucherRechargeService.queryShoppingVoucherRechargeList(rechargeListDTO);
        return Ref.ok(list);
    }

    @ApiOperation("导出购物券充值记录")
    @RequestMapping("rechargeExcel")
    public CommonResult<Void> rechargeExcel(HttpServletRequest request, HttpServletResponse response) throws NormalException {
        shoppingVoucherRechargeService.rechargeExcel(request, response);
        return Ref.ok();
    }

    @ApiOperation("系统管理积分")
    @RequestMapping("sysManagementIntegral")
    @RequiresPermissions("user:sysManagementIntegral")
    public CommonResult<PageUtils> querySysManagementIntegral(ShoppingVoucherRechargeListDTO rechargeListDTO) {
        PageUtils integral = shoppingVoucherRechargeService.querySysManagementIntegral(rechargeListDTO);
        return Ref.ok(integral);
    }
}
